package com.real.fact.web.customer.domain;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.real.fact.web.sale.domain.Check;
import com.real.fact.web.sale.domain.Ticket;

@Entity
@Table(name = "payment")
public class Payment {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "id", nullable = false)
  private long id;

  @Column(name = "amount_cash")
  private float amountCash;

  @Column(name = "amount_credit")
  private float amountCreditCard;

  @Column(name = "amount_debit")
  private float amountDebitCard;

  @ManyToOne
  private Customer customer;

  @Column(name = "Date")
  private Date date;

  @Column(name = "Description")
  private String description;

  @Enumerated(EnumType.STRING)
  private Ticket ticket;

  @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
  private Check check;

  protected Payment() {
    // nothing to do
  }

  public Payment(final float theAmountCash,
      final float theAmountDebitCard, final float theAmountCreditCard,
      final Customer theCustomer, final String theDescription,
      final Check theCheck, final Ticket theTicket) {
    amountCash = theAmountCash;
    amountDebitCard = theAmountDebitCard;
    amountCreditCard = theAmountCreditCard;
    customer = theCustomer;
    date = new Date();
    description = theDescription;
    ticket = theTicket;
  }

  public long getId() {
    return id;
  }

  public Customer getCustomer() {
    return customer;
  }

  public Date getDate() {
    return date;
  }

  public String getDescription() {
    return description;
  }

  public float getAmountCash() {
    return amountCash;
  }

  public float getAmountCreditCard() {
    return amountCreditCard;
  }

  public float getAmountDebitCard() {
    return amountDebitCard;
  }

  public Ticket getTicket() {
    return ticket;
  }

  public Check getCheck() {
    return check;
  }

}
